//**********************************************************************
//  PP5_3.java   Author: Tang Caiming
//
//  从键盘键入一个整数，判断其奇数、偶数和零数字的个数.
//**********************************************************************

import java.util.Scanner;

public class PP5_3
{
   //-------------------------------------------------------------------
   //  判断一个数的奇、偶及零数字的个数.
   //-------------------------------------------------------------------
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      int odd = 0, even = 0, zero = 0;  //  奇数，偶数，零数的个数；
      int number;

      System.out.println("Enter the number you typed from the keyboard: ");
      number = scan.nextInt();

      String numberStr = number + "";
      int numberlength = numberStr.length();

      int flag = 0;
      //一位一位的截取
      for (int i = 0; i < numberlength; i++)
      {
         flag = Integer.valueOf(numberStr.substring(i, i + 1));
            if (flag == 0)
               zero++;
            else
               if (flag % 2 != 0 && flag != 0)
                  odd++;
               else
                  even++;
      }
      System.out.println("奇数个数: " + odd + "\n" + "偶数个数: " + even + "\n" + "0的个数" + zero);
   }
}
